package java6681.analysis;

import java.util.Scanner;

public class GetValue6681 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串：");
        String line = sc.nextLine();
        int num = parseInt6681(line);
        System.out.println("剔除非数字得到的数字：");
        System.out.println(num);
    }

    public static int parseInt6681(String s) {
        String num = "";
        for (int i = 0; i < s.length(); i++) {
            if (Character.isDigit(s.charAt(i))){
                num += s.charAt(i);
                }
            }
            if (num.length() == 0){
                return 0;
        }
        return Integer.parseInt(num);
    }
}
